package spring.aop;

import spring.beans.ImportBeanDefinitionRegistrar;
import spring.beans.config.BeanDefinition;
import spring.beans.factory.DefaultListableBeanFactory;

/**
 * 实现了ImportBeanDefinitionRegistrar，
 * 往IoC容器中添加特定的bean
 */
public class AspectJAutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
    @Override
    public void registerBeanDefinitions(DefaultListableBeanFactory registry) {
        /**
         * AOP的处理入口
         * 原方法registerAspectJAnnotationAutoProxyCreatorIfNecessary
         * 注册AnnotationAwareAspectJAutoProxyCreator
         * 主要用于AspectJ注解
         */
        String beanName = "AnnotationAwareAspectJAutoProxyCreator";
        registry.registerBeanDefinition(beanName,new BeanDefinition(AnnotationAwareAspectJAutoProxyCreator.class,"singleton"));
    }
}
